﻿using Abp.Application.Services;
using Abp.Domain.Repositories;
using Batman.Cms.Core.Models.Mvc;
using Batman.Jianbei.Forum.Core.Domains.Dicts;
using Batman.Jianbei.Forum.Core.Domains.Pumps;
using System.Linq;

namespace Batman.Jianbei.Forum.Services.Dicts
{
    public class PumpModelManager : ApplicationService
    {
        public IRepository<PumpModel, string> Repository { get; set; }

        public IRepository<PumpSaleInfo, string> PumSaleInfoRepo { get; set; }

        /// <summary>
        /// 是否可以删除胰岛素泵型号
        /// </summary>
        /// <param name="pumpModelId">胰岛素泵型号</param>
        /// <returns></returns>
        public bool CanDelete(string pumpModelId)
        {
            var saleInfoExists = PumSaleInfoRepo.GetAll().Any(t => t.PumpModelId == pumpModelId);

            if (saleInfoExists)
                return false;

            return true;
        }
    }
}
